import { request } from 'umi';

// export async function createUser(params) {
//   return request(`/api/admin/users`, {
//     method: 'POST',
//     params,
//   });
// }

/**
 * 获取商品列表数据
 * @param {*} params
 * @returns
 */
export async function getGoods(data) {
  return request(`/api/admin/goods`, {
    method: 'GET',
    data,
  });
}

/**
 * 获取商品列表数据
 * @param {*} params
 * @returns
 */
export async function getGoodDetial(id) {
  return request(`/api/admin/goods/${id}?include=category`, {
    method: 'GET',
  });
}

/**
 * 设置商品上下架
 * @param {*} params
 * @returns
 */
export async function goodsOn(good) {
  return request(`/api/admin/goods/${good}/on`, {
    method: 'PATCH',
  });
}
/**
 * 设置商品上下推荐
 * @param {*} params
 * @returns
 */
export async function goodsRecommend(good) {
  return request(`/api/admin/goods/${good}/recommend`, {
    method: 'PATCH',
  });
}
/**
 * 添加商品
 * @param {*} params
 * @returns
 */
export async function addGoods(params) {
  return request(`/api/admin/goods`, {
    method: 'POST',
    params,
  });
}
/**
 * 更新商品
 * @param {*} params
 * @returns
 */
export async function updateGoods(id, data) {
  return request(`/api/admin/goods/${id}`, {
    method: 'PUT',
    data,
  });
}
/**获取商品分类
 * @param {*} params
 * @returns
 */
export async function getCategory() {
  return request(`/api/admin/category`, {
    method: 'GET',
    params: {
      type: 'all',
    },
  });
}
